home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 400_01 / socketpp-1.5 / test / tdunread.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  1.1 KB  |  49 lines

  1. // tdunread.cc. Test for -*- C++ -*- socket library
  2. // Copyright (C) 1992,1993 Gnanasekaran Swaminathan <gs4t@virginia.edu>
  3. // 
  4. // Permission is granted to use at your own risk and distribute this software
  5. // in source and binary forms provided the above copyright
  6. // notice and this paragraph are preserved on all copies.
  7. // This software is provided "as is" with no express or implied warranty.
  8. //
  9. // Version: 07Nov93 1.5
  10.  
  11. #include <sockunix.h>
  12.  
  13. extern "C" {
  14.     int    chmod (const char* path, int mode);
  15.     void perror (const char*);
  16.     int    unlink (const char* path);
  17. }
  18.  
  19. main(int ac, char** av)
  20. {
  21.     if (ac != 2) {
  22.     cerr << "USAGE: " << av[0] << " socket_path_name\n";
  23.     return 1;
  24.     }
  25.     
  26.     isockunix     su (sockbuf::sock_dgram);
  27.     
  28.     su->bind(av[1]);
  29.     
  30.     cout << "Socket name = " << av[1] << endl;
  31.     
  32.     if (chmod (av[1], 0777) == -1) {
  33.     perror("chmod");
  34.     return 1;
  35.     }
  36.     
  37.     char buf[1024];
  38.     int i;
  39.     su >> i;
  40.     cout << av[0] << ": " << i << " strings: ";
  41.     while (i--) {
  42.     su >> buf;
  43.     cout  << buf << ' ';
  44.     }
  45.     cout << endl;
  46.     
  47.     unlink(av[1]);
  48. }
  49.